<?php

$dsn = 'mysql:dbname=MyBlog;host=192.168.76.11';
$user = 'root';
$password = '123456';
try {
    $dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
    echo 'Connection failed: ' . $e->getMessage();
}

$sql="SELECT * FROM tb_article";

$sql2="SELECT * FROM tb_classes";

$statement = $dbh->query($sql);
if($statement === false ){
    die('SQL出错'.$dbh->errorInfo()[2]);
}
$rs_list = $statement->fetchAll(PDO::FETCH_ASSOC);

$statement = $dbh->query($sql2);
if($statement === false ){
    die('SQL出错'.$dbh->errorInfo()[2]);
}
$rs_classes = $statement->fetchAll(PDO::FETCH_ASSOC);

$id = $_GET['id'];

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Blog Design</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
	<div id="header">
		<span class="logo">That is Amazing!</span>
		<ul id="menu">
			<li><a href="index.php"><img src="images/but1.gif" alt="" width="64" height="42" /></a></li>
			<li><a href="index.php"><img src="images/but2.gif" alt="" width="108" height="42" /></a></li>
			<li><a href="index.php"><img src="images/but3.gif" alt="" width="93" height="42" /></a></li>
		</ul>
		<img src="images/spacer.gif" alt="setalpm" width="120" height="120" border="0" usemap="#Map" class="rss" />
        <map name="Map">
          <area shape="circle" coords="60,60,63" href="">
      </map>
	</div>
	<div id="content1">
        <?php
        foreach ($rs_list as $KEY) {
            if($KEY['ID'] == $id) {
                echo '<div >
                          <div class="title" style="text-align:center;color: #474747;">
                              <h2>';
                echo $KEY['Title'];

                echo '</h2>
                        </div>
                <div  style="text-align:center;color: #474747; " >
                    <span class="datetime" ><h6>';
                echo '发布时间：' . $KEY['PublishTime'] . '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . '分类：<a style="text-decoration:none;color: #474747;" href="">';
                foreach ($rs_classes as $KEY1) {
                    if($KEY1['ClassID'] == $KEY['ClassID'])
                        echo $KEY1['ClassName'];
                }
                echo '</a></h6>
              </span>
                </div>
                <div class="contents">';
                echo $KEY['Contents'];
                echo '
                            
                </div>
            </div>';
            }
        }
        ?>
			<div id="comments">
				<img src="images/title3.gif" alt="" width="216" height="39" /><br />
				<div class="comment">

				</div>
				<div id="add">
					<img src="images/title4.gif" alt="" width="216" height="47" class="title" /><br />
					<div class="avatar">
						<img src="images/avatar2.gif" alt="" width="80" height="80" /><br />
						<span>Name User</span><br />
						April 12th
</div>
					<div class="form">
						<form action="#">
							<textarea placeholder="Your Message..."></textarea><br />
							<input type="text" placeholder="Name" /><br />
							<input type="text" placeholder="E-mail" /><br />
							<input type="text" placeholder="URL (Optional)" /><br />
							<a href="index.php"><img src="images/button.gif" alt="" width="94" height="27" /></a>
						</form>
					</div>
				</div>
			</div>
		</div>
		<div id="sidebar">

		</div>
	</div>
	<div id="footer">
		<p>Copyright &copy;. All rights reserved.</p>
	</div>
</body>
</html>
